home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / cpp_libs / rwvector.lha / RWVector2.1 / rw / RComplex.h < prev    next >
C/C++ Source or Header  |  1989-08-18  |  2KB  |  92 lines

  1. #ifndef RCOMPLEX_H
  2. #define RCOMPLEX_H
  3. #pragma once
  4.  
  5. /*
  6.  *    Complex
  7.  *
  8.  *    Copyright (C) 1988, 1989.
  9.  *
  10.  *    Dr. Thomas Keffer
  11.  *    Rogue Wave Associates
  12.  *    P.O. Box 85341
  13.  *    Seattle WA 98145-1341
  14.  *
  15.  *    Permission to use, copy, modify, and distribute this
  16.  *    software and its documentation for any purpose and
  17.  *    without fee is hereby granted, provided that the
  18.  *    above copyright notice appear in all copies and that
  19.  *    both that copyright notice and this permission notice
  20.  *    appear in supporting documentation.
  21.  *    
  22.  *    This software is provided "as is" without any
  23.  *    expressed or implied warranty.
  24.  *
  25.  *
  26.  *    @(#)RComplex.h    2.1    8/18/89
  27.  */
  28.  
  29. /* Because there are so many variations of "Complex" types, this 
  30.  * header file attempts to standardize what the other routines see.
  31.  */
  32.  
  33. #include "vdefs.h"
  34.  
  35. #if NEEDS_OVERLOAD
  36. overload    conj;
  37. overload    real;
  38. overload    imag;
  39. overload    norm;
  40. overload    arg;
  41. #endif
  42.  
  43. #if defined(__GNUG__) || defined(__ATT__)
  44. //    Define true if sizeof(Complex)==2*sizeof(double)
  45. #define COMPLEX_PACKS 1
  46. #endif
  47.  
  48. // Figure out which header file to use
  49. #ifdef __GNUG__
  50.  
  51. #include <Complex.h>
  52.  
  53. #else
  54.  
  55. #ifdef __ATT2__
  56. // The V2.0 version will work
  57. #include <complex.h>
  58. #else
  59. // Use the modified local copy:
  60. #include "complex.h"
  61. #endif
  62.  
  63. #endif
  64.  
  65.  
  66. #ifdef __GNUG__
  67.  
  68. // The GNU library uses a capital "C", and passes by
  69. // reference.
  70. #define DComplex Complex
  71. typedef DComplex (*CmathFunTy)(DComplex&);
  72. typedef double (*CmathFunTy2)(DComplex&);
  73.  
  74. #else
  75.  
  76. // The AT&T version uses a small "c", and passes by
  77. // value, EXCEPT for real and imag!  why?!
  78. #define DComplex complex
  79. typedef DComplex (*CmathFunTy)(DComplex);
  80. typedef double (*CmathFunTy2)(DComplex);
  81.  
  82. #endif
  83.  
  84. #ifdef __ATT1__
  85. static /* cfront bug requires this */
  86. #else
  87. inline
  88. #endif
  89. double ABSOLUTE(DComplex& a) {return hypot(real(a), imag(a));}
  90.  
  91. #endif
  92.